<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>AdWords API Documentation</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta><link rel="stylesheet" href="../css/template.css" type="text/css"></link></head><body><div id="content"><h1 class="file">Common/Util/SimpleOAuth2Handler.php</h1><div id="file-nav-box"><div id="file-nav-container"><ul id="file-nav"><li><a href="#classes"><img src="../images/icons/class.png" alt="Class" height="14"></img>
                          Classes
                      </a><ul><li><a href="#\SimpleOAuth2Handler">\SimpleOAuth2Handler</a></li></ul></li></ul><div style="clear: left;"></div></div><div id="file-nav-tab">
              Table of Contents
          </div></div><a name="top" class="anchor"></a><div id="file-description"><div class="short-description">A simple OAuth 2.0 handler.</div><div class="long-description"><p>PHP version 5</p>

<p>Copyright 2011, Google Inc. All Rights Reserved.</p>

<p>Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at</p>

<pre><code>http://www.apache.org/licenses/LICENSE-2.0
</code></pre>

<p>Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.</p></div></div><dl class="file-info"><dt>Author</dt><dd>Eric Koleda
         
    </dd><dt>Author</dt><dd>Vincent Tsao
         
    </dd><dt>Category</dt><dd>WebServices
         
    </dd><dt>Copyright</dt><dd>2012, Google Inc. All Rights Reserved.
         
    </dd><dt>License</dt><dd>http://www.apache.org/licenses/LICENSE-2.0 Apache License,
            Version 2.0
         
    </dd><dt>Package</dt><dd>GoogleApiAdsCommon
         
    </dd><dt>Subpackage</dt><dd>Util
         
    </dd></dl><a name="classes" class="anchor"></a><a id="\SimpleOAuth2Handler" class="anchor"></a><h2 class="class">\SimpleOAuth2Handler<div class="to-top"><a href="#top">jump to top</a></div></h2><div class="class"><small class="package"><b>Package: </b>GoogleApiAdsCommon\Util</small><div class="short-description">A simple OAuth 2.0 handler.</div><div class="long-description"></div><dl class="class-info"><dt>Parent(s)</dt><dd><a href="../files/Common.Util.OAuth2Handler.html#\OAuth2Handler">\OAuth2Handler</a></dd></dl><h3>Constants</h3><div><a id="\SimpleOAuth2Handler::REFRESH_BUFFER" class="anchor"></a><div class="constant publicC inherited_from "><a href="#" class="gripper"><img src="../images/icons/arrow_right.png" alt="&gt;"></img><img src="../images/icons/arrow_down.png" alt="V" style="display: none;"></img></a><code class="title"><img src="../images/icons/constant.png" alt="Constant"></img> 
                <span class="highlight">REFRESH_BUFFER</span>
                = 60</code><div class="description"><span class="attribute">inherited</span><div class="short-description">The refresh buffer of 60 seconds.</div><small class="inherited_from">Inherited from:
                        <a href="../files/Common.Util.OAuth2Handler.html#\OAuth2Handler::REFRESH_BUFFER">\OAuth2Handler::REFRESH_BUFFER</a></small></div><div class="code-tabs"><div class="long-description"></div><dl class="constant-info"><dt>Inherited_from</dt><dd><a href="../files/
                         Common.Util.OAuth2Handler.html#\OAuth2Handler::REFRESH_BUFFER">\OAuth2Handler::REFRESH_BUFFER</a>
         
    </dd></dl></div><div class="clear"></div></div><a id="\SimpleOAuth2Handler::DEFAULT_REDIRECT_URI" class="anchor"></a><div class="constant publicC inherited_from "><a href="#" class="gripper"><img src="../images/icons/arrow_right.png" alt="&gt;"></img><img src="../images/icons/arrow_down.png" alt="V" style="display: none;"></img></a><code class="title"><img src="../images/icons/constant.png" alt="Constant"></img> 
                <span class="highlight">DEFAULT_REDIRECT_URI</span>
                = 'urn:ietf:wg:oauth:2.0:oob'</code><div class="description"><span class="attribute">inherited</span><small class="inherited_from">Inherited from:
                        <a href="../files/Common.Util.OAuth2Handler.html#\OAuth2Handler::DEFAULT_REDIRECT_URI">\OAuth2Handler::DEFAULT_REDIRECT_URI</a></small></div><div class="code-tabs"><dl class="constant-info"><dt>Inherited_from</dt><dd><a href="../files/
                         Common.Util.OAuth2Handler.html#\OAuth2Handler::DEFAULT_REDIRECT_URI">\OAuth2Handler::DEFAULT_REDIRECT_URI</a>
         
    </dd></dl></div><div class="clear"></div></div><a id="\SimpleOAuth2Handler::AUTHORIZE_ENDPOINT" class="anchor"></a><div class="constant publicC inherited_from "><a href="#" class="gripper"><img src="../images/icons/arrow_right.png" alt="&gt;"></img><img src="../images/icons/arrow_down.png" alt="V" style="display: none;"></img></a><code class="title"><img src="../images/icons/constant.png" alt="Constant"></img> 
                <span class="highlight">AUTHORIZE_ENDPOINT</span>
                = 'https://accounts.google.com/o/oauth2/auth'</code><div class="description"><span class="attribute">inherited</span><small class="inherited_from">Inherited from:
                        <a href="../files/Common.Util.OAuth2Handler.html#\OAuth2Handler::AUTHORIZE_ENDPOINT">\OAuth2Handler::AUTHORIZE_ENDPOINT</a></small></div><div class="code-tabs"><dl class="constant-info"><dt>Inherited_from</dt><dd><a href="../files/
                         Common.Util.OAuth2Handler.html#\OAuth2Handler::AUTHORIZE_ENDPOINT">\OAuth2Handler::AUTHORIZE_ENDPOINT</a>
         
    </dd></dl></div><div class="clear"></div></div><a id="\SimpleOAuth2Handler::ACCESS_ENDPOINT" class="anchor"></a><div class="constant publicC inherited_from "><a href="#" class="gripper"><img src="../images/icons/arrow_right.png" alt="&gt;"></img><img src="../images/icons/arrow_down.png" alt="V" style="display: none;"></img></a><code class="title"><img src="../images/icons/constant.png" alt="Constant"></img> 
                <span class="highlight">ACCESS_ENDPOINT</span>
                = 'https://accounts.google.com/o/oauth2/token'</code><div class="description"><span class="attribute">inherited</span><small class="inherited_from">Inherited from:
                        <a href="../files/Common.Util.OAuth2Handler.html#\OAuth2Handler::ACCESS_ENDPOINT">\OAuth2Handler::ACCESS_ENDPOINT</a></small></div><div class="code-tabs"><dl class="constant-info"><dt>Inherited_from</dt><dd><a href="../files/
                         Common.Util.OAuth2Handler.html#\OAuth2Handler::ACCESS_ENDPOINT">\OAuth2Handler::ACCESS_ENDPOINT</a>
         
    </dd></dl></div><div class="clear"></div></div></div><h3>Properties</h3><div><a id="\SimpleOAuth2Handler::$curlUtils" class="anchor"></a><div class="property private"><a href="#" class="gripper"><img src="../images/icons/arrow_right.png" alt="&gt;"></img><img src="../images/icons/arrow_down.png" alt="V" style="display: none;"></img></a><code class="title"><img src="../images/icons/property.png" alt="Property"></img><img src="../images/icons/visibility_private.png" style="margin-right: 5px" alt="private"></img><span class="highlight">$curlUtils</span></code><div class="description"></div><div class="code-tabs"><strong>Details</strong><dl class="property-info"><dt>Type</dt><dd>n/a</dd></dl></div><div class="clear"></div></div><a id="\SimpleOAuth2Handler::$scope" class="anchor"></a><div class="property protected inherited_from "><a href="#" class="gripper"><img src="../images/icons/arrow_right.png" alt="&gt;"></img><img src="../images/icons/arrow_down.png" alt="V" style="display: none;"></img></a><code class="title"><img src="../images/icons/property.png" alt="Property"></img><img src="../images/icons/visibility_protected.png" style="margin-right: 5px" alt="protected"></img><span class="highlight">$scope</span></code><div class="description"><span class="attribute">inherited</span><small class="inherited_from">Inherited from:
                        <a href="../files/Common.Util.OAuth2Handler.html#\OAuth2Handler::$$scope">\OAuth2Handler::$$scope</a></small></div><div class="code-tabs"><strong>Details</strong><dl class="property-info"><dt>Type</dt><dd>n/a</dd><dt>Inherited_from</dt><dd><a href="../files/
                         Common.Util.OAuth2Handler.html#\OAuth2Handler::$$scope">\OAuth2Handler::$$scope</a>
         
    </dd></dl></div><div class="clear"></div></div><a id="\SimpleOAuth2Handler::$server" class="anchor"></a><div class="property private inherited_from "><a href="#" class="gripper"><img src="../images/icons/arrow_right.png" alt="&gt;"></img><img src="../images/icons/arrow_down.png" alt="V" style="display: none;"></img></a><code class="title"><img src="../images/icons/property.png" alt="Property"></img><img src="../images/icons/visibility_private.png" style="margin-right: 5px" alt="private"></img><span class="highlight">$server</span></code><div class="description"><span class="attribute">inherited</span><small class="inherited_from">Inherited from:
                        <a href="../files/Common.Util.OAuth2Handler.html#\OAuth2Handler::$$server">\OAuth2Handler::$$server</a></small></div><div class="code-tabs"><strong>Details</strong><dl class="property-info"><dt>Type</dt><dd>n/a</dd><dt>Inherited_from</dt><dd><a href="../files/
                         Common.Util.OAuth2Handler.html#\OAuth2Handler::$$server">\OAuth2Handler::$$server</a>
         
    </dd></dl></div><div class="clear"></div></div></div><h3>Methods</h3><div><a id="\SimpleOAuth2Handler::CanRefreshAccessToken()" class="anchor"></a><div class="method public inherited_from "><a href="#" class="gripper"><img src="../images/icons/arrow_right.png"></img><img src="../images/icons/arrow_down.png" style="display: none;"></img></a><code class="title"><img src="../images/icons/method.png" alt="method" title="method"></img><img src="../images/icons/visibility_public.png" style="margin-right: 5px" alt="public"></img><span class="highlight">CanRefreshAccessToken</span><span class="nb-faded-text">(array $credentials)</span> : boolean</code><div class="description"><span class="attribute">inherited</span><p class="short_description">Determines if the access token can be refreshed.</p><small class="inherited_from">Inherited from:
                    <a href="../files/Common.Util.OAuth2Handler.html#\OAuth2Handler::CanRefreshAccessToken()">\OAuth2Handler::CanRefreshAccessToken()</a></small></div><div class="code-tabs"><div class="long-description"></div><strong>Parameters</strong><table class="argument-info"><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tr><th>$credentials</th><td>array</td><td><em><p>the credentials</p></em></td></tr></table><strong>Returns</strong><table class="argument-info"><thead><tr><th>Type</th><th>Description</th></tr></thead><tr><td>boolean</td><td>TRUE if the credentials can be refreshed</td></tr></table></div><div class="clear"></div></div><a id="\SimpleOAuth2Handler::FormatCredentialsForHeader()" class="anchor"></a><div class="method public inherited_from "><a href="#" class="gripper"><img src="../images/icons/arrow_right.png"></img><img src="../images/icons/arrow_down.png" style="display: none;"></img></a><code class="title"><img src="../images/icons/method.png" alt="method" title="method"></img><img src="../images/icons/visibility_public.png" style="margin-right: 5px" alt="public"></img><span class="highlight">FormatCredentialsForHeader</span><span class="nb-faded-text">(array $credentials)</span> : string</code><div class="description"><span class="attribute">inherited</span><p class="short_description">Formats OAuth2 credentials for use in an HTTP header.</p><small class="inherited_from">Inherited from:
                    <a href="../files/Common.Util.OAuth2Handler.html#\OAuth2Handler::FormatCredentialsForHeader()">\OAuth2Handler::FormatCredentialsForHeader()</a></small></div><div class="code-tabs"><div class="long-description"><p>For example: Bearer token</p></div><strong>Parameters</strong><table class="argument-info"><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tr><th>$credentials</th><td>array</td><td><em><p>the OAuth2 credentials</p></em></td></tr></table><strong>Returns</strong><table class="argument-info"><thead><tr><th>Type</th><th>Description</th></tr></thead><tr><td>string</td><td>the credentials formatted for use in an HTTP header</td></tr></table></div><div class="clear"></div></div><a id="\SimpleOAuth2Handler::FormatCredentialsForUrl()" class="anchor"></a><div class="method public inherited_from "><a href="#" class="gripper"><img src="../images/icons/arrow_right.png"></img><img src="../images/icons/arrow_down.png" style="display: none;"></img></a><code class="title"><img src="../images/icons/method.png" alt="method" title="method"></img><img src="../images/icons/visibility_public.png" style="margin-right: 5px" alt="public"></img><span class="highlight">FormatCredentialsForUrl</span><span class="nb-faded-text">(array $credentials)</span> : string</code><div class="description"><span class="attribute">inherited</span><p class="short_description">Formats OAuth2 credentials for use in a URL.</p><small class="inherited_from">Inherited from:
                    <a href="../files/Common.Util.OAuth2Handler.html#\OAuth2Handler::FormatCredentialsForUrl()">\OAuth2Handler::FormatCredentialsForUrl()</a></small></div><div class="code-tabs"><div class="long-description"><p>For example: access_token=token.</p></div><strong>Parameters</strong><table class="argument-info"><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tr><th>$credentials</th><td>array</td><td><em><p>the OAuth2 credentials</p></em></td></tr></table><strong>Returns</strong><table class="argument-info"><thead><tr><th>Type</th><th>Description</th></tr></thead><tr><td>string</td><td>the credentials formatted for use in a URL</td></tr></table></div><div class="clear"></div></div><a id="\SimpleOAuth2Handler::GetAccessEndpoint()" class="anchor"></a><div class="method protected inherited_from "><a href="#" class="gripper"><img src="../images/icons/arrow_right.png"></img><img src="../images/icons/arrow_down.png" style="display: none;"></img></a><code class="title"><img src="../images/icons/method.png" alt="method" title="method"></img><img src="../images/icons/visibility_protected.png" style="margin-right: 5px" alt="protected"></img><span class="highlight">GetAccessEndpoint</span><span class="nb-faded-text">(array $params = NULL)</span> : string</code><div class="description"><span class="attribute">inherited</span><p class="short_description">Gets the access endpoint using the given server and parameters.</p><small class="inherited_from">Inherited from:
                    <a href="../files/Common.Util.OAuth2Handler.html#\OAuth2Handler::GetAccessEndpoint()">\OAuth2Handler::GetAccessEndpoint()</a></small></div><div class="code-tabs"><div class="long-description"></div><strong>Parameters</strong><table class="argument-info"><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tr><th>$params</th><td>array</td><td><em><p>the parameters to include in the endpoint</p></em></td></tr></table><strong>Returns</strong><table class="argument-info"><thead><tr><th>Type</th><th>Description</th></tr></thead><tr><td>string</td><td>the access endpoint</td></tr></table></div><div class="clear"></div></div><a id="\SimpleOAuth2Handler::GetAccessToken()" class="anchor"></a><div class="method public"><a href="#" class="gripper"><img src="../images/icons/arrow_right.png"></img><img src="../images/icons/arrow_down.png" style="display: none;"></img></a><code class="title"><img src="../images/icons/method.png" alt="method" title="method"></img><img src="../images/icons/visibility_public.png" style="margin-right: 5px" alt="public"></img><span class="highlight">GetAccessToken</span><span class="nb-faded-text">(array $credentials, string $code, string $redirectUri = NULL)</span> : array</code><div class="description"><p class="short_description">Gets the access token for an authorized request token.</p></div><div class="code-tabs"><div class="long-description"></div><strong>Parameters</strong><table class="argument-info"><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tr><th>$credentials</th><td>array</td><td><em><p>the credentials, including client_id and
    client_secret</p></em></td></tr><tr><th>$code</th><td>string</td><td><em><p>the authorization code returned in the response</p></em></td></tr><tr><th>$redirectUri</th><td>string</td><td><em><p>optional callback URL</p></em></td></tr></table><strong>Returns</strong><table class="argument-info"><thead><tr><th>Type</th><th>Description</th></tr></thead><tr><td>array</td><td>the credentials passed in plus access_token, expires_in,
    timestamp and optionally refresh_token if offline mode was requested</td></tr></table><strong>Details</strong><dl class="function-info"><dt>See</dt><dd>\OAuth2Hanlder::GetAccessToken()
         
    </dd></dl></div><div class="clear"></div></div><a id="\SimpleOAuth2Handler::GetAuthorizationUrl()" class="anchor"></a><div class="method public inherited_from "><a href="#" class="gripper"><img src="../images/icons/arrow_right.png"></img><img src="../images/icons/arrow_down.png" style="display: none;"></img></a><code class="title"><img src="../images/icons/method.png" alt="method" title="method"></img><img src="../images/icons/visibility_public.png" style="margin-right: 5px" alt="public"></img><span class="highlight">GetAuthorizationUrl</span><span class="nb-faded-text">(array $credentials, string $redirectUri = NULL, boolean $offline = NULL, array $params = NULL)</span> : string</code><div class="description"><span class="attribute">inherited</span><p class="short_description">Gets the authorization URL to redirect to.</p><small class="inherited_from">Inherited from:
                    <a href="../files/Common.Util.OAuth2Handler.html#\OAuth2Handler::GetAuthorizationUrl()">\OAuth2Handler::GetAuthorizationUrl()</a></small></div><div class="code-tabs"><div class="long-description"></div><strong>Parameters</strong><table class="argument-info"><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tr><th>$credentials</th><td>array</td><td><em><p>the credentials, including client_id</p></em></td></tr><tr><th>$redirectUri</th><td>string</td><td><em><p>optional callback URL</p></em></td></tr><tr><th>$offline</th><td>boolean</td><td><em><p>whether or not to request offline access (aka a
    refresh token), false by default</p>
</em></td></tr><tr><th>$params</th><td>array</td><td><em><p>optional array of additional parameters to include
    in the URL</p></em></td></tr></table><strong>Returns</strong><table class="argument-info"><thead><tr><th>Type</th><th>Description</th></tr></thead><tr><td>string</td><td>an authorization URL to redirect the user to</td></tr></table><strong>Details</strong><dl class="function-info"><dt>See</dt><dd>\https://developers.google.com/accounts/docs/OAuth2WebServer#formingtheurl
         
    </dd></dl></div><div class="clear"></div></div><a id="\SimpleOAuth2Handler::GetAuthorizeEndpoint()" class="anchor"></a><div class="method protected inherited_from "><a href="#" class="gripper"><img src="../images/icons/arrow_right.png"></img><img src="../images/icons/arrow_down.png" style="display: none;"></img></a><code class="title"><img src="../images/icons/method.png" alt="method" title="method"></img><img src="../images/icons/visibility_protected.png" style="margin-right: 5px" alt="protected"></img><span class="highlight">GetAuthorizeEndpoint</span><span class="nb-faded-text">(array $params = NULL)</span> : string</code><div class="description"><span class="attribute">inherited</span><p class="short_description">Gets the authorization endpoint using the given server and parameters.</p><small class="inherited_from">Inherited from:
                    <a href="../files/Common.Util.OAuth2Handler.html#\OAuth2Handler::GetAuthorizeEndpoint()">\OAuth2Handler::GetAuthorizeEndpoint()</a></small></div><div class="code-tabs"><div class="long-description"></div><strong>Parameters</strong><table class="argument-info"><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tr><th>$params</th><td>array</td><td><em><p>the parameters to include in the endpoint</p></em></td></tr></table><strong>Returns</strong><table class="argument-info"><thead><tr><th>Type</th><th>Description</th></tr></thead><tr><td>string</td><td>the authorization endpoint</td></tr></table></div><div class="clear"></div></div><a id="\SimpleOAuth2Handler::GetEndpoint()" class="anchor"></a><div class="method private inherited_from "><a href="#" class="gripper"><img src="../images/icons/arrow_right.png"></img><img src="../images/icons/arrow_down.png" style="display: none;"></img></a><code class="title"><img src="../images/icons/method.png" alt="method" title="method"></img><img src="../images/icons/visibility_private.png" style="margin-right: 5px" alt="private"></img><span class="highlight">GetEndpoint</span><span class="nb-faded-text">(string $endpoint, array $params = NULL)</span> : string</code><div class="description"><span class="attribute">inherited</span><p class="short_description">Gets an endpoint using the given server and parameters.</p><small class="inherited_from">Inherited from:
                    <a href="../files/Common.Util.OAuth2Handler.html#\OAuth2Handler::GetEndpoint()">\OAuth2Handler::GetEndpoint()</a></small></div><div class="code-tabs"><div class="long-description"></div><strong>Parameters</strong><table class="argument-info"><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tr><th>$endpoint</th><td>string</td><td><em><p>the base endpoint URL to use</p></em></td></tr><tr><th>$params</th><td>array</td><td><em><p>the parameters to include in the endpoint</p></em></td></tr></table><strong>Returns</strong><table class="argument-info"><thead><tr><th>Type</th><th>Description</th></tr></thead><tr><td>string</td><td>the endpoint</td></tr></table></div><div class="clear"></div></div><a id="\SimpleOAuth2Handler::GetExpiryTimestamp()" class="anchor"></a><div class="method private inherited_from "><a href="#" class="gripper"><img src="../images/icons/arrow_right.png"></img><img src="../images/icons/arrow_down.png" style="display: none;"></img></a><code class="title"><img src="../images/icons/method.png" alt="method" title="method"></img><img src="../images/icons/visibility_private.png" style="margin-right: 5px" alt="private"></img><span class="highlight">GetExpiryTimestamp</span><span class="nb-faded-text">(array $credentials)</span> : int | boolean</code><div class="description"><span class="attribute">inherited</span><p class="short_description">Get the expiry of a given credential, or false if none is found.</p><small class="inherited_from">Inherited from:
                    <a href="../files/Common.Util.OAuth2Handler.html#\OAuth2Handler::GetExpiryTimestamp()">\OAuth2Handler::GetExpiryTimestamp()</a></small></div><div class="code-tabs"><div class="long-description"></div><strong>Parameters</strong><table class="argument-info"><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tr><th>$credentials</th><td>array</td><td><em><p>the credentials, including access_token,
    timestamp and expires_in</p></em></td></tr></table><strong>Returns</strong><table class="argument-info"><thead><tr><th>Type</th><th>Description</th></tr></thead><tr><td>int | boolean</td><td>utc timestamp if exists or FALSE if none found</td></tr></table></div><div class="clear"></div></div><a id="\SimpleOAuth2Handler::GetOrRefreshAccessToken()" class="anchor"></a><div class="method public inherited_from "><a href="#" class="gripper"><img src="../images/icons/arrow_right.png"></img><img src="../images/icons/arrow_down.png" style="display: none;"></img></a><code class="title"><img src="../images/icons/method.png" alt="method" title="method"></img><img src="../images/icons/visibility_public.png" style="margin-right: 5px" alt="public"></img><span class="highlight">GetOrRefreshAccessToken</span><span class="nb-faded-text">(array $credentials)</span> : array</code><div class="description"><span class="attribute">inherited</span><p class="short_description">Get the valid access token or the token if needed and possible.</p><small class="inherited_from">Inherited from:
                    <a href="../files/Common.Util.OAuth2Handler.html#\OAuth2Handler::GetOrRefreshAccessToken()">\OAuth2Handler::GetOrRefreshAccessToken()</a></small></div><div class="code-tabs"><div class="long-description"></div><strong>Parameters</strong><table class="argument-info"><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tr><th>$credentials</th><td>array</td><td><em><p>the credentials, including client_id and
    client_secret</p></em></td></tr></table><strong>Returns</strong><table class="argument-info"><thead><tr><th>Type</th><th>Description</th></tr></thead><tr><td>array</td><td>the credentials passed in plus any refreshed credentials
    if they were refreshed</td></tr></table></div><div class="clear"></div></div><a id="\SimpleOAuth2Handler::IsAccessTokenExpiring()" class="anchor"></a><div class="method public inherited_from "><a href="#" class="gripper"><img src="../images/icons/arrow_right.png"></img><img src="../images/icons/arrow_down.png" style="display: none;"></img></a><code class="title"><img src="../images/icons/method.png" alt="method" title="method"></img><img src="../images/icons/visibility_public.png" style="margin-right: 5px" alt="public"></img><span class="highlight">IsAccessTokenExpiring</span><span class="nb-faded-text">(array $credentials)</span> : boolean</code><div class="description"><span class="attribute">inherited</span><p class="short_description">Tests if the access token is about to expire or has expired.</p><small class="inherited_from">Inherited from:
                    <a href="../files/Common.Util.OAuth2Handler.html#\OAuth2Handler::IsAccessTokenExpiring()">\OAuth2Handler::IsAccessTokenExpiring()</a></small></div><div class="code-tabs"><div class="long-description"></div><strong>Parameters</strong><table class="argument-info"><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tr><th>$credentials</th><td>array</td><td><em><p>the credentials, including access_token,
    timestamp and expires_in</p></em></td></tr></table><strong>Returns</strong><table class="argument-info"><thead><tr><th>Type</th><th>Description</th></tr></thead><tr><td>boolean</td><td>TRUE if the token has expired</td></tr></table></div><div class="clear"></div></div><a id="\SimpleOAuth2Handler::IsAccessTokenValid()" class="anchor"></a><div class="method public inherited_from "><a href="#" class="gripper"><img src="../images/icons/arrow_right.png"></img><img src="../images/icons/arrow_down.png" style="display: none;"></img></a><code class="title"><img src="../images/icons/method.png" alt="method" title="method"></img><img src="../images/icons/visibility_public.png" style="margin-right: 5px" alt="public"></img><span class="highlight">IsAccessTokenValid</span><span class="nb-faded-text">(array $credentials)</span> : boolean</code><div class="description"><span class="attribute">inherited</span><p class="short_description">Determines if the access token is still valid.</p><small class="inherited_from">Inherited from:
                    <a href="../files/Common.Util.OAuth2Handler.html#\OAuth2Handler::IsAccessTokenValid()">\OAuth2Handler::IsAccessTokenValid()</a></small></div><div class="code-tabs"><div class="long-description"><p>If expiry information isn't
available then this function will assume it is.</p></div><strong>Parameters</strong><table class="argument-info"><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tr><th>$credentials</th><td>array</td><td><em><p>the credentials, including access_token,
    timestamp and expires_in</p></em></td></tr></table><strong>Returns</strong><table class="argument-info"><thead><tr><th>Type</th><th>Description</th></tr></thead><tr><td>boolean</td><td>TRUE if the access token is valid or if expiring
    information isn't available</td></tr></table></div><div class="clear"></div></div><a id="\SimpleOAuth2Handler::MakeRequest()" class="anchor"></a><div class="method protected"><a href="#" class="gripper"><img src="../images/icons/arrow_right.png"></img><img src="../images/icons/arrow_down.png" style="display: none;"></img></a><code class="title"><img src="../images/icons/method.png" alt="method" title="method"></img><img src="../images/icons/visibility_protected.png" style="margin-right: 5px" alt="protected"></img><span class="highlight">MakeRequest</span><span class="nb-faded-text">(string $url, array $params)</span> : \OAuthToken</code><div class="description"><p class="short_description">Makes an HTTP request to the given URL and extracts the returned OAuth2
response.</p></div><div class="code-tabs"><div class="long-description"></div><strong>Parameters</strong><table class="argument-info"><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tr><th>$url</th><td>string</td><td><em><p>the URL to make the request to</p></em></td></tr><tr><th>$params</th><td>array</td><td><em><p>the parameters to include in the POST body</p></em></td></tr></table><strong>Returns</strong><table class="argument-info"><thead><tr><th>Type</th><th>Description</th></tr></thead><tr><td>\OAuthToken</td><td>the returned token</td></tr></table></div><div class="clear"></div></div><a id="\SimpleOAuth2Handler::RefreshAccessToken()" class="anchor"></a><div class="method public"><a href="#" class="gripper"><img src="../images/icons/arrow_right.png"></img><img src="../images/icons/arrow_down.png" style="display: none;"></img></a><code class="title"><img src="../images/icons/method.png" alt="method" title="method"></img><img src="../images/icons/visibility_public.png" style="margin-right: 5px" alt="public"></img><span class="highlight">RefreshAccessToken</span><span class="nb-faded-text">(array $credentials)</span> : array</code><div class="description"><p class="short_description">Refreshes the access token.</p></div><div class="code-tabs"><div class="long-description"></div><strong>Parameters</strong><table class="argument-info"><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tr><th>$credentials</th><td>array</td><td><em><p>the credentials, including the client_id,
    client_secret, refresh_token</p></em></td></tr></table><strong>Returns</strong><table class="argument-info"><thead><tr><th>Type</th><th>Description</th></tr></thead><tr><td>array</td><td>the credentials</td></tr></table><strong>Details</strong><dl class="function-info"><dt>See</dt><dd>\OAuth2Hanlder::RefreshAccessToken()
         
    </dd></dl></div><div class="clear"></div></div><a id="\SimpleOAuth2Handler::ShouldRefreshAccessToken()" class="anchor"></a><div class="method public inherited_from "><a href="#" class="gripper"><img src="../images/icons/arrow_right.png"></img><img src="../images/icons/arrow_down.png" style="display: none;"></img></a><code class="title"><img src="../images/icons/method.png" alt="method" title="method"></img><img src="../images/icons/visibility_public.png" style="margin-right: 5px" alt="public"></img><span class="highlight">ShouldRefreshAccessToken</span><span class="nb-faded-text">(array $credentials)</span> : boolean</code><div class="description"><span class="attribute">inherited</span><p class="short_description">Determines if the access token should be refreshed.</p><small class="inherited_from">Inherited from:
                    <a href="../files/Common.Util.OAuth2Handler.html#\OAuth2Handler::ShouldRefreshAccessToken()">\OAuth2Handler::ShouldRefreshAccessToken()</a></small></div><div class="code-tabs"><div class="long-description"></div><strong>Parameters</strong><table class="argument-info"><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tr><th>$credentials</th><td>array</td><td><em><p>the credentials, including client_id and
    client_secret</p></em></td></tr></table><strong>Returns</strong><table class="argument-info"><thead><tr><th>Type</th><th>Description</th></tr></thead><tr><td>boolean</td><td>TRUE if the Access Token should be refreshed</td></tr></table></div><div class="clear"></div></div><a id="\SimpleOAuth2Handler::__construct()" class="anchor"></a><div class="method public"><a href="#" class="gripper"><img src="../images/icons/arrow_right.png"></img><img src="../images/icons/arrow_down.png" style="display: none;"></img></a><code class="title"><img src="../images/icons/method.png" alt="method" title="method"></img><img src="../images/icons/visibility_public.png" style="margin-right: 5px" alt="public"></img><span class="highlight">__construct</span><span class="nb-faded-text">(string $server = NULL,  $scope = NULL, <a href="../files/Common.Util.CurlUtils.html#\CurlUtils">\CurlUtils</a> $curlUtils = NULL)</span> : void</code><div class="description"><p class="short_description">Creates a new instance of this OAuth handler.</p></div><div class="code-tabs"><div class="long-description"></div><strong>Parameters</strong><table class="argument-info"><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tr><th>$server</th><td>string</td><td><em><p>the auth server to make OAuth2 request against</p></em></td></tr><tr><th>$scope</th><td></td><td><em></em></td></tr><tr><th>$curlUtils</th><td><a href="../files/Common.Util.CurlUtils.html#\CurlUtils">\CurlUtils</a></td><td><em><p>an instance of CurlUtils</p></em></td></tr></table></div><div class="clear"></div></div></div></div></div><small class="footer">
            Documentation was generated by
            <a href="http://phpdoc.org">phpDocumentor
                2.0.0a12</a>.
        </small></body></html>
